package com.itheima.blackitheima.blackithema1;

import java.util.Iterator;
import java.util.TreeSet;

public class MyTreeSet1 {
    public static void main(String[] args) {
        //创建TreeSet集合
        TreeSet<Student> ts=new TreeSet<>();
        //创建Student对象
        Student stu1=new Student("heiehi",80,80,90);
        Student stu2=new Student("weiwei",78,65,100);
        Student stu3=new Student("beibei",95,87,90);
        Student stu4=new Student("lili",100,100,97);
        ts.add(stu1);
        ts.add(stu2);
        ts.add(stu3);
        ts.add(stu4);
        //迭代器
        Iterator<Student> it = ts.iterator();
        while(it.hasNext()){
            System.out.println(it.next());
        }
        System.out.println("===============");
        //超级for
        for (Student t : ts) {
            System.out.println(t);

        }
        System.out.println("--------------------");
        //超级for
        for (Student t : ts) {
            System.out.println(t.getName()+"  "+t.getChinese()+" "+t.getMath()+" "+t.getEnglish());
        }
    }
}
